<?php namespace Admin\Controller;
use Hdphp\Controller\Controller;
class TagController extends CommonController{
	private $model;
	public function __init(){
//		调用commonController里面的构造方法__init(包含验证是否登录)；
		parent::__init();
		$this->model=new \Common\Model\Tag;		
			}
		//	标签展示
		 public function index(){
		 	$data=$this->model->get();
			View::with('data',$data);
		 	View::make();
		 }
//      添加标签
	     public function add(){
	     	if(IS_POST){
	     		if($this->model->store()) View::success('添加成功',U('index'));
				View::error($this->model->getError());
	     	}
		 View::make();
	   }
//		 删除
		 public function del(){
		 $tid=Q('get.tid',0,'intval');		 
		 $this->model->where('tid='.$tid)->delete();
		 View::success('删除成功',U('index'));
		 	
		 }
//		 修改
		 public function edit(){
		 	if(IS_POST){
		 		if($this->model->edit()) View::success('编辑成功',U('index'));
				View::error($this->model->getError());
		 	  }									
		 	$tid=Q('get.tid',0,'intval');
		 	$oldData=$this->model->where("tid={$tid}")->find();
			View::with('oldData',$oldData);
		 	View::make();
			
		 }
		 
}
 ?>